Skip to content

fix(deploy): remove unreachable null-signer guard in resolveSignerSetup#110

Merged
EnderOfWorlds007 merged 3 commits into
mainfrom
fix/dead-signer-guard
May 4, 2026
Merged

fix(deploy): remove unreachable null-signer guard in resolveSignerSetup#110
EnderOfWorlds007 merged 3 commits into
mainfrom
fix/dead-signer-guard

Conversation

@EnderOfWorlds007

Copy link
Copy Markdown
Collaborator

Context

Closes #104 (Bug 2).

Bug 1 from that issue (error message not mentioning --suri) was already fixed on mainSignerNotAvailableError now reads 'No signer available. Run "dot init" to log in, or pass --suri //Alice for dev.'

This PR addresses Bug 2 only.

Problem

resolveSignerSetup in src/utils/deploy/signerMode.ts contained a dead error branch:

if (opts.publishToPlayground) {
    if (!opts.userSigner) {
        throw new Error(
            'Publishing to Playground requires a logged-in account. Run "dot init" first, or drop --playground.',
        );
    }
    ...
}

The !opts.userSigner guard can never be true when publishToPlayground is true. The invariant is enforced one level up:

  • shouldResolveUserSigner() returns true whenever opts.publishToPlayground === true (signerMode.ts:256)
  • When that returns true, resolveSigner() is called in the preflight (deploy/index.ts:203)
  • resolveSigner() either produces a ResolvedSigner or throws SignerNotAvailableError — it never returns null
  • The preflight rethrows any SignerNotAvailableError when publishToPlayground is set (deploy/index.ts:208-209)

So by the time resolveSignerSetup is called, userSigner is guaranteed non-null. The throw was dead code.

Fix

  • Delete the if (!opts.userSigner) throw branch
  • Replace with opts.userSigner! (non-null assertion) to keep TypeScript happy
  • Add a comment explaining the invariant so a future refactor doesn't silently reintroduce the same guard thinking it's needed

Testing

  • pnpm exec tsc --noEmit — passes clean
  • No behaviour change on any reachable path

The throw at signerMode.ts:142-149 could never fire: shouldResolveUserSigner()
returns true whenever publishToPlayground is true, so resolveSigner() in the
preflight has already either produced a ResolvedSigner or rethrown before
resolveSignerSetup is called. Replace the dead branch with a non-null assertion
and a comment explaining the invariant so the next refactor doesn't silently
reintroduce it.

Closes #104.
@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Dev build ready — try this branch:

curl -fsSL https://raw.githubusercontent.com/paritytech/playground-cli/main/install.sh | VERSION=dev/fix/dead-signer-guard bash

@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

E2E Test Pass · ✅ PASS

Tag: e2e-ci-pr · Branch: fix/dead-signer-guard · Commit: d1b2562 · Run logs

Cell Result Time
pr-deploy-foundry ✅ PASS 1m34s
pr-deploy-frontend ✅ PASS 8m45s
pr-mod ✅ PASS 1m25s
pr-install ✅ PASS 0m42s
pr-preflight ✅ PASS 3m28s
pr-init-session ✅ PASS 1m21s
${{ matrix.cell }} ⏭️ SKIP 0m00s
${{ matrix.cell }} ⏭️ SKIP 0m00s

Sentry traces: view spans for this run

@EnderOfWorlds007 EnderOfWorlds007 merged commit 1988832 into main May 4, 2026
17 checks passed
@UtkarshBhardwaj007 UtkarshBhardwaj007 deleted the fix/dead-signer-guard branch May 4, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading error messages: --suri is a valid alternative to 'dot init' for --playground deploys

1 participant